package mfund.com.controller;

import java.util.*;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.ServletContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import mfund.com.service.*;
import mfund.com.model.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;  
import javax.servlet.http.HttpServletResponse;  
import javax.servlet.http.HttpSession; 
import java.io.IOException;



@Controller
public class LoginController
{
	@Resource
	private LoginService loginService;

	@RequestMapping(value="loginData",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_VALUE)
	public @ResponseBody MFResult getProducts(HttpServletRequest request, 
		HttpServletResponse response,
		@RequestParam String userName,
		@RequestParam String password,
		@RequestParam String isChecked) throws IOException
	{
		MFResult map=new MFResult();
		HttpSession session = request.getSession(true);
        List<TUser> tusers=loginService.query(userName,password);
        if(tusers.size()==0){
        	map.setStatusFail();
        }else{
        	session.setAttribute("flag", userName);
        	map.setData("manageProduct.html"); 
        }
		return map;
	}
}